#include<iostream>
#include<string>
using namespace std;
char b[150];
void Print(string a)
{
	int len = a.size();
	for (int i = 'a'; i <= 'z'; i++)
	{
		for (int j = 0; j < len; j++)
		{
			if (a[j] == (char)i) {
				b[i]++;
			}
		}
	}
	for (int i = 'a'; i <= 'z'; i++)
	{
		cout << (char)i << ":" << (int)b[i] << endl;
	}
}
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		string s1;
		string s2;
		cin >> s1;
		getchar();
		cin >> s2;
		int n;
		cin >> n;
		if (n == 0) {
			Print(s1);
		}
		else if (n == 1) {
			Print(s2);
		}
		else {
			string ans;
			for (int i = 2; i <= n; i++) {
				ans = s1 + s2;
				s1 = s2;
				s2 = ans;
			}
			Print(ans);
		}
	}
	return 0;
}
